﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Person.Domain;
using T_Person.Read.APi.Applaction.Command.Employment;
using T_Person.Read.APi.Dto;

namespace T_Person.Read.APi.Controllers
{
    /// <summary>
    /// 人事信息显示
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PersonnelController : ControllerBase
    {
        private readonly IMediator mediator;

        public PersonnelController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 人事入职查询分页
        /// </summary>
        /// <param name="employmentSearchByResult"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GetPageResultbyEmployment([FromQuery]EmploymentSearchByResult employmentSearchByResult)
        {
            return await mediator.Send(employmentSearchByResult);
        }
        /// <summary>
        /// 人事转正查询分页
        /// </summary>
        /// <param name="regularCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GetPageResultByRegular([FromQuery]RegularCommand regularCommand)
        {
            return await mediator.Send(regularCommand);
        }
        /// <summary>
        /// 离职查询
        /// </summary>
        /// <param name="resignationCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GetPageResultByResignation([FromQuery]ResignationCommand resignationCommand)
        {
            return await mediator.Send(resignationCommand);
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="employmentSearchByidCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Personnel> GetPersonnelByid([FromQuery]EmploymentSearchByidCommand employmentSearchByidCommand)
        {
            return await mediator.Send(employmentSearchByidCommand);
        }
        /// <summary>
        /// 审批入职显示
        /// </summary>
        /// <param name="employeementByApprovalCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GetEmployeementByApprvel([FromQuery] EmployeementByApprovalCommand employeementByApprovalCommand)
        {
            return await mediator.Send(employeementByApprovalCommand);
        }
        /// <summary>
        /// 审批转正
        /// </summary>
        /// <param name="regularSearchByApprovelCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GerRegularByapprovel([FromQuery]RegularSearchByApprovelCommand regularSearchByApprovelCommand)
        {
            return await mediator.Send(regularSearchByApprovelCommand);
        }
        /// <summary>
        /// 审批离职显示
        /// </summary>
        /// <param name="resignationSearchByApprovelCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Personnel>> GetPageResultByResignationandApprovel([FromQuery]ResignationSearchByApprovelCommand resignationSearchByApprovelCommand)
        {
            return await mediator.Send(resignationSearchByApprovelCommand);
        }
        /// <summary>
        /// 通过主键获取人员的主键和当前状态的数组
        /// </summary>
        /// <param name="employeeSearchStateArrayByidCommand"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<StateArray> GetStateArrayByid([FromQuery]EmployeeSearchStateArrayByidCommand employeeSearchStateArrayByidCommand)
        {
            return await mediator.Send(employeeSearchStateArrayByidCommand);
        }
    }
}
